'''
Created on Oct 25, 2011

@author: baiamc
'''

import pygame
from pygame.locals import *

class Game(object):
    '''
    Main game object
    '''
    
    #Color definitions
    black = (0, 0, 0)
    white = (255, 255, 255)
    green = (0, 180, 0)


    def __init__(self):
        '''
        Constructor
        '''
        self._running = True
        self.size = self.width, self.height = 800, 600
    
    def on_init(self):
        pygame.init()
        self._screen = pygame.display.set_mode(self.size, pygame.HWSURFACE | pygame.DOUBLEBUF)
        self._background = pygame.Surface(self._screen.get_size())
        self._background = self._background.convert()
        self._background.fill(Game.green)
        
    def on_event(self, event):
        if event.type == pygame.QUIT:
            self._running = False
    
    def on_loop(self):
        pass
    
    def on_render(self):
        self._screen.blit(self._background,(0,0))
        pygame.display.flip()
    
    def on_cleanup(self):
        pygame.quit()
        
    def on_execute(self):
        if self.on_init() == False:
            self._running = False
        
        while (self._running):
            for event in pygame.event.get():
                self.on_event(event)
            self.on_loop()
            self.on_render()
        self.on_cleanup()
            
if __name__ == '__main__':
    theGame = Game()
    theGame.on_execute()
